package yingke.com.yingke;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.view.Window;

import com.avos.avoscloud.AVUser;

import yingke.com.yingke.ui.LoginActivity;
import yingke.com.yingke.ui.MainActivity;


public class WelcomActivity extends AppCompatActivity {

    private Handler handler = new Handler(new Handler.Callback() {
        @Override
        public boolean handleMessage(Message msg) {

            return false;
        }
    });
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_welcom);
        AVUser currentUser = AVUser.getCurrentUser();
        if (currentUser == null) {
            handler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    startActivity(new Intent(WelcomActivity.this, LoginActivity.class));
                    finish();
                }
            },3000);

        } else {
            handler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    startActivity(new Intent(WelcomActivity.this, MainActivity.class));
                    finish();
                }
            },3000);
        }
    }
}
